package com.yoyosys.service.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;

import com.yoyosys.entity.SysRole;
import com.yoyosys.entity.UserDetailsImpl;
import com.yoyosys.entity.UserVo;

/** 
 * @Description: TODO
 * @ClassName: UserDetailsServiceImpl 
 * @author: knight
 * @date: 2018年3月8日 下午9:45:39  
 */
public class UserDetailsServiceImpl implements UserDetailsService{

	/* (non Javadoc) 
	 * @param arg0
	 * @return
	 * @throws UsernameNotFoundException
	 * @Title: loadUserByUsername 
	 * @see org.springframework.security.core.userdetails.UserDetailsService#loadUserByUsername(java.lang.String) 
	 */
	@Override
	public UserDetails loadUserByUsername(String name) throws UsernameNotFoundException {
		UserVo sysUser = new UserVo();
		sysUser.setUsername(name);
		sysUser.setPassword("$2a$10$HYZrpx/6sfFK7l7JWCleL..iX2lTlGK4NzGQg4QQi11P3CPb/FNMO");
		sysUser.setDelFlag("0");
		List<SysRole> roleList = new ArrayList<>();
		SysRole role = new SysRole();
		role.setRoleId(1);
		role.setRoleName("admin");
		role.setRoleCode("admins");
		roleList.add(role);
		sysUser.setRoleList(roleList);
		return new UserDetailsImpl(sysUser);
	}

}
